import React, { useContext } from "react";
import { Navigate } from "react-router-dom";
import { context } from "../components/AppProvider";

function ProtectedRoute({ children }: any) {
  const { isLogin } = useContext(context);
  return isLogin ? children : <Navigate to="/login" />;
}

export default ProtectedRoute;
